home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / term / vltj5867.lha / VLT / rexx / SCPMouse.rexx < prev    next >
OS/2 REXX Batch file  |  1992-03-11  |  2KB  |  97 lines

  1. /** SCPMouse.rexx
  2. *
  3. *   Example of how to receive mouse move messages from VLT and to
  4. *   send arrow keys to the host. This version is designed for use
  5. *   with the SLAC SCP program, where each horizontal arrow moves
  6. *   the "cursor" by 10 spaces, and each vertical arrow moves it by
  7. *   4 lines. There is also room at the bottom, etc. to take into
  8. *   account.
  9. *
  10. *   Willy langeveld, version March 1992.
  11. *
  12. **/
  13. parse arg vltport .
  14. address value vltport
  15.  
  16. quitflag = 0
  17.  
  18. if showlist('p', vltport'SCPMOUSE') = 1 then exit
  19.  
  20. mp = openport(vltport'SCPMOUSE')
  21.  
  22. do forever
  23.    if quitflag = 1 then leave
  24.    t = waitpkt(vltport'SCPMOUSE')
  25.    do forever
  26.       p = getpkt(vltport'SCPMOUSE')
  27.       if c2d(p) = 0 then leave
  28.  
  29.       string = getarg(p)
  30.       t = reply(p, 0)
  31.  
  32.       parse var string xx yy ytot
  33.       yy = yy - (ytot - 28)
  34.       if yy < 0 then iterate
  35.       if yy > 24 then iterate
  36.  
  37.       newx = (xx) % 10
  38.       newy = (yy) % 3
  39. /*
  40. *   Cursor home
  41. */
  42.       send "(*E[4~)"
  43. /*
  44. *   Move in X. either from first to the right...
  45. */
  46.       if newx < 4 then do
  47.          send "(*E[C)"
  48.          if newx < 8 & newx > -1 then do
  49.             do i = 1 to newx
  50.                send "(*E[C)"
  51.             end
  52.          end
  53.       end
  54. /*
  55. *   ...or from home backwards
  56. */
  57.       else do
  58.          newx = 7 - newx
  59.          if newx < 8 & newx > -1 then do
  60.             do i = 1 to newx
  61.                send "(*E[D)"
  62.             end
  63.          end
  64.       end
  65. /*
  66. *   Move in Y. Either from home down...
  67. */
  68.       if newy < 4 then do
  69.          if newy < 8 & newy > -1 then do
  70.             do i = 1 to newy
  71.                send "(*E[B)"
  72.             end
  73.          end
  74.       end
  75. /*
  76. *   ...or from bottom up.
  77. */
  78.       else do
  79.          send "(*E[A)"
  80.          newy = 7 - newy
  81.          if newy < 8 & newy > -1 then do
  82.             do i = 1 to newy
  83.                send "(*E[A)"
  84.             end
  85.          end
  86.       end
  87. /*
  88. *   Send enter key
  89. */
  90.       "delay .3; send (*EOM)"
  91.    end
  92. end
  93.  
  94. /* This example doesn't really ever: */
  95. exit
  96.  
  97.